package cn.edu.scau.cmi.dengzejun.chapter11;

import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.event.*;

public class WindowMouse extends JFrame{
	JTextField text;
	JButton button;
	JTextArea textArea;
	PoliceMouse police;
	WindowMouse(){
		this.init();
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		return;
	}
	
	private void init() {
		this.setLayout(new FlowLayout());
		this.text = new JTextField(8);
		this.textArea = new JTextArea(5,28);
		this.police = new PoliceMouse();
		this.police.setJTextArea(this.textArea);
		this.text.addMouseListener(this.police);
		this.button = new JButton("Button");
		this.button.addMouseListener(this.police);
		this.addMouseListener(this.police);
		this.add(this.button);
		this.add(this.text);
		this.add(new JScrollPane(this.textArea));
		return;
	}
}
